<template>
	<view class="page_view">
		<view class="list_item" v-for="(item,index) in list" :key="index" @click="handleClickAddressItem(item)">
			<view class="list_item_top">
				<text class="list_item_top_moren" v-if="item.is_default == 1">默认</text>
				{{item.province_text}}{{item.city_text}}{{item.area_text}}
			</view>
			<view class="list_item_min flex">
				<view class="list_item_min_left">
					{{item.address}}
				</view>
				<image src="https://bucketoss10086.oss-cn-beijing.aliyuncs.com/images/binaji.png"  class="list_item_min_icon" mode="" @click="go_EditAddress(index)"></image>
			</view>
			<view class="list_item_bottom">
				{{item.name}} <text class="list_item_bottom_phone">{{item.mobile}}</text>
			</view>
		</view>
		<view>
			<u-empty text="地址暂无数据" mode="list"></u-empty>
		</view>
		<view class="btn" @click="add_address">
			新增收货地址
		</view>
	</view>
</template>

<script>
	import { address } from '../../api/common.js';
	export default {
		data() {
			return {
				list:[]
			}
		},
		mounted() {
			this.getList();
		},
		methods: {
			getList(){
				address().then(res=>{
					if(res.code == 200001){
						this.list = res.data.data;
					}
				})
			},
			add_address(){
				uni.navigateTo({
					url:'/pages/MyAddress/AddAddress/AddAddress'
				})
			},
			go_EditAddress(index){
				uni.navigateTo({
					url:'/pages/MyAddress/AddAddress/AddAddress?data=' + JSON.stringify(this.list[index])
				})
			},
			handleClickAddressItem(item) {
				uni.setStorageSync('addressData', item)
				uni.navigateTo({
					url: uni.getStorageSync('addressUrl')
				})
			}
		}
	}
</script>

	
<style>
	page{
		background-color: #fff;
	}
	.page_view{
		padding: 0 30rpx;
		box-sizing: border-box;
	}
.list_item{
	width: 100%;
	height: 196rpx;
	border-bottom: 1rpx solid #F4F4F4;
	padding: 30rpx 0;
	box-sizing: border-box;
}
.list_item_top_moren{
	display: inline-flex;
	padding: 4rpx 20rpx;
	border-radius: 8rpx;
	background: #0165FB;
	color: #FFF;
	font-family: Source Han Sans SC;
	font-size: 20rpx;
	font-weight: 400;
	margin-right: 12rpx;
}
.list_item_top{
	color: #666;
	font-family: Source Han Sans SC;
	font-size: 24rpx;
	font-weight: 400;
}
.list_item_min{
	margin-top: 10rpx;
}
.list_item_min_icon{
	width: 30rpx;
	height: 30rpx;
}
.list_item_bottom_phone{
	margin-left: 40rpx;
}
.list_item_bottom{
	color: #666;
	font-family: Source Han Sans SC;
	font-size: 24rpx;
	font-weight: 400;
	margin-top: 10rpx;
}
.list_item_min_left{
	color: #333;
	font-family: Source Han Sans SC;
	font-size: 30rpx;
	font-weight: 400;
}
.btn{
	width: 690rpx;
	height: 80rpx;
	border-radius: 40rpx;
	background: #0165FB;
	text-align: center;
	line-height: 80rpx;
	color: #FFF;
	text-align: center;
	font-family: Alibaba PuHuiTi 2.0;
	font-size: 28rpx;
	font-weight: 400;
	position: fixed;
	bottom: 70rpx;
	left: 30rpx;
}
</style>
